define(function (require) {
var zsApp = require('app');
zsApp.controller( 'userRolesDetailsController',["$scope", "$http", "$location","$state","$rootScope","$cookieStore", "$timeout", "promptCache",function( $scope, $http, $location , $state,$rootScope,$cookieStore,$timeout,promptCache){
	
	//从cookie取rolesdetails
	$scope.rolesdetailsnew = $cookieStore.get('rolesdetails');
	$scope.rolesupdatenew = $cookieStore.get('rolesupdate');
	
	//console.log($scope.rolesdetailsnew.roleGroupId);
	console.log($scope.rolesdetailsnew);
	
	$scope.rolesdetailsblock = function(){
		//$cookieStore.remove('$scope.rolesdetails');
		$state.go("user.roles",{},{reload:true});
	}
	
	// 确认修改（用于用户修改原有的数据）
	$scope.confirmEdit = function($event,$index) {
		// 修改角色组名、描述（封装成JSON）
		
		var editData = {
			roleGroupId   : $scope.rolesupdatenew.roleGroupId,
			roleGroupName : $scope.rolesupdatenew.roleGroupName,
			description   : $scope.rolesupdatenew.description,
		}

		$http({
			url   	: $scope.zsUrl+'digitalhome-boss/admin/roleGroups/modify',
			method  : 'POST',
			data    : editData, /* 将JSON发送给服务器 */
		}).then(function success(res){
			console.log(editData);
			// 重新加载页面
			if( '0000' == res.data.result_code ){
				promptCache.successPrompt("修改角色组成功");
			}else{
				promptCache.errorPrompt("修改角色组失败");
			}
		}, 
		function error(err) 
		{
			console.log(err);
		});
	}
	
	
	
	
	
}])
});